package basicgrammer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainTest {

	/**
	 * @param args
	 */
	private final static StringBuffer test = new StringBuffer("hello world");
	private TestObject to;
	public String getTest() {
		return test.toString();
	}
	public String setTest(String s){
		test.replace(0, test.length(), "");
		test.append(s);
		return "";
	}
	public String setTest(){
		test.replace(0, test.length(), "");
		return "";
	}
	public TestObject getTo(){
		return to;
	}
	public void setTo(TestObject t){
		to.setSb(t.getSb());
		
	}
	public void setTo(){
		to = new TestObject();
		to.setSb(" new sb");
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
/*		MainTest m= new MainTest();
		MainTest mt = new MainTest();
		try{
		m.setTest(" again");
		m.setTo();
		System.out.println(m.getTest());
		System.out.println(m.getTo().getSb());
		System.out.println(m.toString());
		m.setTest();
		TestObject t = new TestObject();
		t.setSb("new test object");
		m.setTo(t);
		System.out.println(m.getTest()+"**");
		System.out.println(m.toString());
		mt.setTo();
		mt.setTo(m.getTo());
		System.out.println(m.getTo().getSb()+"**");
		System.out.println(mt.getTo().getSb());
		MainTest mt2 = new MainTest();
		if(mt2.getTest()!=null){
			System.out.println("mt2's final string test is not null");
		}
		if(mt2.getTo()!=null){
			System.out.println("mt2's object to is not null");
		}
		
		}catch(Exception e){
			e.printStackTrace();
		}
		finally{
//			System.out.println(m.getTest()+"*");
//			System.out.println(m.toString());
		}*/
		
		TestObj2 t= new TestObj2();
		TestObj2 m = t;
		System.out.println("hello");
		for(int i =0;i<5;i++){
			System.out.println("count = "+(i+1));
			if(m!=null){
			System.out.println(m.getSr());
			System.out.println(m.getT());
			m=m.getT();
			}
		}
		TestObj2 m2 = new TestObj2();
		System.out.println(m2.getSr());
		System.out.println(m2.getT());
//		t.getClass().getClass();
		ArrayList arraylist = new ArrayList();
		arraylist.add("hello1");
		arraylist.add("hello2");
		arraylist.add("hello3");
		arraylist.add("hello4");
		arraylist.remove(0);
		arraylist.remove(0);
		System.out.println("+++"+arraylist.size()+"++"+arraylist.get(0));
		int[] int1 = new int[3];
		int[] int2 = new int[5];
		Arrays.fill(int1, 3);
		System.arraycopy(int1, 0, int2, 0, int1.length);
		System.out.println(Arrays.toString(int2));
		
		StringBuffer sb = new StringBuffer("1");
		StringBuffer sb2 = sb;
		sb.append("je");
		System.out.println("sb is"+sb+"sb2 is"+sb2);
	////difference bettwen object and container
		List<StringBuffer> li2 = new ArrayList<StringBuffer> ();
		li2.add(new StringBuffer("1"));
		 li2.get(0).append("h");
		li2.add(new StringBuffer("2"));
		Object temp = li2.get(0);
		li2.get(0).append("h");
		li2.clear();
//		li2.set(0, li2.get(1));
		System.out.println("temp"+temp);
//		li2.set(1, temp);
		System.out.println(li2);
		Object str1 = new String("12");
		Object str2 = new String("12");
		System.out.println("the result of object '12' and object '12' equals "+ str1.equals(str2));
		
		
		
	}

}
